package likou.jindian;

/**
 * @Info:
 * @Author: Tangxz
 * @Date: 2020/09/20 12:30
 */
public class _01_03 {
    public static void main(String[] args) {
        String ww = "     ";
//        ww.
//        System.out.println(ww.replace(" ", "%20"));
//        for (int i = 0; i < ww.length(); i++) {
//            System.out.println(i + "  " + (ww.charAt(i)==' '));
//        }
//        int i = 1;
//        char now = (char) ('a'+i);
//        String www = String.valueOf(now);
//        System.out.println(now);
//        if((ww.length()-ww.replace(www,"").length())%2==1){
//        }
        System.out.println(replaceSpaces("Mr John Smith    ",13));

    }
    public static String replaceSpaces(String S, int length) {
        char[] chs = S.toCharArray();
        int i = length - 1, j = S.length() - 1;
        while(i >= 0) {
            if(chs[i] == ' ') {
                chs[j--] = '0';
                chs[j--] = '2';
                chs[j--] = '%';
            } else {
                chs[j--] = chs[i];
            }
            --i;
        }
        return String.valueOf(chs,j + 1, S.length() - j - 1);
    }
}
